package com.beta.service.impl;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import com.beta.mapper.MenuActionsMapper;
import com.beta.entity.MenuActions;
import com.beta.service.IMenuActionsService;
import com.baomidou.framework.service.impl.SuperServiceImpl;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 *
 * MenuActions 表数据服务层接口实现类
 *
 */
@Service
public class MenuActionsService extends SuperServiceImpl<MenuActionsMapper, MenuActions> implements IMenuActionsService {

    @Override
    public Map<Integer, List<MenuActions>> getMenuActionsMap() {
        List<MenuActions> menuActions = baseMapper.selectList(null);
        if (CollectionUtils.isEmpty(menuActions)) {
            return Collections.emptyMap();
        }

        return menuActions.stream().collect(Collectors.groupingBy(MenuActions::getMenuId));
    }

}